import React from 'react';
import { hot } from 'react-hot-loader';
import { HashRouter as Router } from 'react-router-dom';
import { Provider } from 'mobx-react';
import Store from './store';
import Page from './page';
import 'normalize.css';
import './App.less';
import './api/mock'; // 模拟数据

// 初始化并缓存全局状态，热更新友好
window.store = window.store || new Store();
const store = window.store as Store;

// 状态初始化设置
store.view.setTitle('项目'); // 设置标题
store.user.onLogin(true); // 设置为已登录

/**
 * 注入层
 */
const App = () => (
  <Provider store={store}>
    <Router>
      <Page />
    </Router>
  </Provider>
);

export default (process.env.NODE_ENV === 'development' ? hot(module)(App) : App);
